#include "qabstractscrollareahost.h"

#include "../property/qabstractproperty.h"
#include "../qpropertyfactory.h"
#include "../qcommonstruct.h"

QAbstractScrollAreaHost::QAbstractScrollAreaHost(QAbstractHost *parent):
    QFrameHost(parent)
{
    setProperty("need_frame",false);
    setProperty("accept_drop",false);
}


void QAbstractScrollAreaHost::init_property()
{
    QFrameHost::init_property();

    QAbstractProperty* pro;

    pro=QPropertyFactory::create_property("Enum");
    if(pro!=NULL)
    {
        pro->set_property("name","horizontalScrollBarPolicy");
        pro->set_attribute("show_name",tr("Horizontal ScrollBar Policy"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        ComboItems items;
        tagComboItem item;

        item.m_text=tr("ScrollBar As Needed");
        item.m_value=Qt::ScrollBarAsNeeded;
        items.append(item);

        item.m_text=tr("ScrollBar Always Off");
        item.m_value=Qt::ScrollBarAlwaysOff;
        items.append(item);

        item.m_text=tr("ScrollBar Always On");
        item.m_value=Qt::ScrollBarAlwaysOn;
        items.append(item);

        pro->set_attribute("items",QVariant::fromValue<ComboItems>(items));
        m_object->setProperty("horizontalScrollBarPolicy",Qt::ScrollBarAsNeeded);
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Enum");
    if(pro!=NULL)
    {
        pro->set_property("name","verticalScrollBarPolicy");
        pro->set_attribute("show_name",tr("Vertical ScrollBar Policy"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        ComboItems items;
        tagComboItem item;

        item.m_text=tr("ScrollBar As Needed");
        item.m_value=Qt::ScrollBarAsNeeded;
        items.append(item);

        item.m_text=tr("ScrollBar Always Off");
        item.m_value=Qt::ScrollBarAlwaysOff;
        items.append(item);

        item.m_text=tr("ScrollBar Always On");
        item.m_value=Qt::ScrollBarAlwaysOn;
        items.append(item);

        pro->set_attribute("items",QVariant::fromValue<ComboItems>(items));
        m_object->setProperty("verticalScrollBarPolicy",Qt::ScrollBarAsNeeded);
        insert_property(pro);
    }
}

void QAbstractScrollAreaHost::setHorizontalScrollBarPolicy(int horizontalScrollBarPolicy)
{
    set_property_value("horizontalScrollBarPolicy",horizontalScrollBarPolicy);
}

int QAbstractScrollAreaHost::horizontalScrollBarPolicy()
{
    return get_property_value("horizontalScrollBarPolicy").toInt();
}

void QAbstractScrollAreaHost::setVerticalScrollBarPolicy(int verticalScrollBarPolicy)
{
    set_property_value("verticalScrollBarPolicy",verticalScrollBarPolicy);
}

int QAbstractScrollAreaHost::verticalScrollBarPolicy()
{
    return get_property_value("verticalScrollBarPolicy").toInt();
}
